#include <stdio.h>  
  
int main(void)  
{  
    //Read file  
    const charchar *filename1="data\\test.dat";  
    FILEFILE *pFile1;  
    pFile1 = fopen(filename1,"r");  
    if (NULL == pFile1)  
    {  
        printf("Failed to open file to read!");  
        return 1;  
    }  
      
    //Write file  
    const charchar *filename2 = "data\\output.dat";  
    FILEFILE *pFile2 = fopen(filename2, "w");  
    if (NULL == pFile2)  
    {  
        printf("Failed to open file to write!");  
        return 1;  
    }  
      
    //data option  
    char target[10];  
    double longitude = 0;  
    double latitude = 0;  
    double velocity = 0;  
    double head = 0;  
      
    //data item  
    char targetName[10];  
    char longitudeName[10];  
    char latitudeName[10];  
    char velocityName[10];  
    char headName[10];  
      
    //line number  
    int lineNum = 0;  
    char str[80];  
  
    while (!feof(pFile1))  
    {  
        fgets(str, sizeof(str), pFile1);  
        if (0 == lineNum)  
        {  
            sscanf(str, " %s %s %s %s %s", targetName, longitudeName, latitudeName, velocityName, headName);  
            fprintf(pFile2, "%s\t%s\t%s\t%s\t%s\n", targetName, longitudeName, latitudeName, velocityName, headName);  
        }  
        else  
        {  
            sscanf(str, "%s %lf %lf %lf %lf", target, &longitude, &latitude, &velocity, &head);  
            fprintf(pFile2, "%s\t%lf\t%lf\t%lf\t%lf\n", target, longitude, latitude, velocity, head);  
        }  
          
        lineNum++;  
    }  
  
  
    fclose(pFile1);  
    fclose(pFile2);  
  
    return 0;  
} 